package wisp.gui;

//GTGE GUI
import com.golden.gamedev.gui.*;
import com.golden.gamedev.gui.toolkit.*;

//JFC
import java.awt.Color;

//wisp
import wisp.dataObjects.*;
import wisp.game.PlayerSprite;

public class NotificationWindow extends TFloatPanel{


	private PlayerSprite player;
	private GUImanager frame;
	
	private int count;
	private int mx;
	private int my;
	
	private TPanel[] msgBox = new TPanel[12];
	private Cbutton[] msgIcon = new Cbutton[12];
	private TLabel[] msgLabel = new TLabel[12];
	
	private String[] title = new String[12];
	private Message[] messages = new Message[12];
	
	
	public NotificationWindow(PlayerSprite p, GUImanager g){
		super("Inbox", true, true, 600, 100, 160, 300);
		
		player = p;
		frame = g;
		count = 0;
		mx = 0;
		my = 0;
		
	}
	
	public boolean addMessage(String t, Message m){
		boolean result = false;

		if(count < 12){
			title[count] = t;
			messages[count] = m;
			
			msgBox[count] = new TPanel(mx, my, 160, 22);
			msgIcon[count] = new Cbutton("N", 5, 5, 12,12);
			
			msgLabel[count] = new TLabel(m.title, 20, 5, 120, 15);
		
			msgBox[count].add(msgIcon[count]);
			msgBox[count].add(msgLabel[count]);
			this.add(msgBox[count]);
			
			count++;
			my += 22;
			
			result = true;
			
			System.out.println("[SYSTEM] msg created @ slot" + count);
		}
		else
		{
			System.out.println("[SYSTEM] Inbox full, cannot add message.");
			result = false;
		}
		return result;
	}
	
	public int getCount(){
		return count;
	}
	
	public void updateThis(){
		for(int i = 0; i < count; i++){
			if(msgIcon[i].clicked()){
				//if()
				frame.createMessage(messages[i]);
				System.out.println("LALALAa create!");
				msgIcon[i].clearClick();
			}
		}
	}
	
	public void removeMsg(int pos){
		//TO DO!
	}
	
	
	

}
